package com.example.educationalsystem.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.educationalsystem.entity.SelectCourse;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.educationalsystem.entity.Vo.ScoreVo;
import com.example.educationalsystem.entity.Vo.SelectCourseVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zpc
 * @since 2022-12-20
 */
@Repository
public interface ISelectCourseMapper extends BaseMapper<SelectCourse> {
    @Select("<script>" +
            "select a.*,b.student_name,b.student_sex,c.*,d.* \n" +
            "from select_course a  \n" +
            "left join student b on a.student_id=b.student_id \n" +
            "left join course c on a.course_id=c.course_id \n"+
            "left join teacher d on d.teacher_id=c.teacher_id \n"+
            "</script>")
    List<SelectCourseVo> getAllSelectCourse();
    @Select("<script>" +
            "select a.*,b.student_name,b.student_sex,c.*,d.* \n" +
            "from select_course a  \n" +
            "left join course c on a.course_id=c.course_id \n"+
            "left join teacher d on c.teacher_id=d.teacher_id \n"+
            "left join student b on a.student_id=b.student_id  where 1=1 \n" +
            "<if test='ew != null'>" +
            " AND ${ew.SqlSegment}" +
            "</if>"
            + "</script>")
    Page<SelectCourseVo> getSelectCoursePage(Page<SelectCourseVo> page, @Param("ew") Wrapper wrapper);
}
